<!-- 保养 -->
<template>
  <div>
    <h4>关联计划</h4>
    <el-table v-loading="loading" :data="noticeList">
      <el-table-column label="保养计划编号" align="center" min-width="130" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.upkeepPlanNum || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="标题" align="center" min-width="130" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.title || '-' }}
        </template>
      </el-table-column>

      <el-table-column label="负责人" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.headName || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="循环类型" align="center" min-width="120">
        <template slot-scope="scope">
          {{ ['循环保养', '单次保养'][scope.row.cycleType] || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="生成任务" align="center" min-width="120">
        <template slot-scope="scope">
          {{ ['提前一日', '提前二日', '提前三日', '提前四日', '提前五日'][scope.row.generateTaskType] || '-' }}
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <h4>关联标准</h4>
    <el-table v-loading="loadingtwo" :data="noticeListtwo">
      <el-table-column label="标准编号" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.levelNum || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="标准名称" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.levelName || '-' }}
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="totaltwo > 0" :total="totaltwo" :page.sync="queryParamstwo.pageNum"
      :limit.sync="queryParamstwo.pageSize" @pagination="getListtwo" />

    <h4>保养记录</h4>
    <el-table v-loading="loadingtherr" :data="noticeListtherr">
      <el-table-column label="序号" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column label="保养任务编号" align="center" min-width="150">
        <template slot-scope="scope">
          {{ scope.row.upkeepTaskNum || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="生成日期" align="center" min-width="150">
        <template slot-scope="scope">
          {{ scope.row.generateTime || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="验收人" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.ukPlanPartInfoVo && scope.row.ukPlanPartInfoVo.acceptorName || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="验收人部门" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.ukPlanPartInfoVo && scope.row.ukPlanPartInfoVo.acceptanceDeptName || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="验收方式" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.ukPlanPartInfoVo && scope.row.ukPlanPartInfoVo.acceptanceModeName || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="保养状态" align="center" min-width="130" show-overflow-tooltip>
        <template slot-scope="scope">
          <span v-for="(item, index) in scope.row.upkeepTaskStatuses" :key="index">
            <dict-tag :options="upkeepStatus" :value="item.upkeepStatus" />
            <span v-if="index !== scope.row.upkeepTaskStatuses.length - 1">/</span>
          </span>
        </template>
      </el-table-column>
      <el-table-column label="验收状态" align="center" min-width="130" show-overflow-tooltip>
        <template slot-scope="scope">
          <span v-for="(item, index) in scope.row.upkeepTaskStatuses" :key="index">
            <dict-tag :options="upkeepStatus" :value="item.acceptanceStatus" />
            <span v-if="index !== scope.row.upkeepTaskStatuses.length - 1">/</span>
          </span>
        </template>
      </el-table-column>
      <el-table-column label="验收说明" align="center" min-width="130" show-overflow-tooltip>
        <template slot-scope="scope">
          <span v-for="(item, index) in scope.row.upkeepTaskStatuses" :key="index">
            {{ item.explanation || '-' }}
            <span v-if="index !== scope.row.upkeepTaskStatuses.length - 1">/</span>
          </span>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="totaltherr > 0" :total="totaltherr" :page.sync="queryParamstherr.pageNum"
      :limit.sync="queryParamstherr.pageSize" @pagination="getListtherr" />
  </div>
</template>

<script>
import { getupkeeplist, getupkeeplevellist, getupkeeptasklist } from "@/api/equipment/equipment.js";
export default {
  name: 'maintainance',
  props: ['rowObj'],
  data () {
    return {
      //关联计划
      total: 0,
      loading: false,
      noticeList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderByColumn: 'upkeepPlanId',
        isAsc: 'desc'//倒叙
      },
      //关联标准
      totaltwo: 0,
      loadingtwo: false,
      noticeListtwo: [],
      // 查询参数
      queryParamstwo: {
        pageNum: 1,
        pageSize: 10,
        orderByColumn: 'upkeepLevelId',
        isAsc: 'desc'//倒叙
      },
      //保养记录
      totaltherr: 0,
      loadingtherr: false,
      noticeListtherr: [],
      // 查询参数
      queryParamstherr: {
        pageNum: 1,
        pageSize: 10,
        // orderByColumn: 'id',
        isAsc: 'desc'//倒叙
      },
    }
  },
  created () {
    this.getList();//关联计划
    this.getListtwo();//关联标准
    this.getListtherr();//保养记录
  },
  methods: {
    async getList () {
      this.loading = true
      let params = {
        ...this.queryParams,
        'params[equipmentAccountId]': this.rowObj.equipmentAccountId
      }
      let data = await getupkeeplist(params);
      this.total = data.total
      this.noticeList = data.data
      this.loading = false
    },
    async getListtwo () {
      this.loadingtwo = true
      let params = {
        ...this.queryParamstwo,
        'params[equipmentAccountId]': this.rowObj.equipmentAccountId
      }
      let data = await getupkeeplevellist(params);
      this.totaltwo = data.total
      this.noticeListtwo = data.data
      this.loadingtwo = false
    },
    async getListtherr () {
      this.loadingtherr = true
      let params = {
        ...this.queryParamstherr,
        equipmentAccountId: this.rowObj.equipmentAccountId
      }
      let data = await getupkeeptasklist(params);
      this.totaltherr = data.total
      this.noticeListtherr = data.data
      this.loadingtherr = false
    }
  }
}
</script>

<style>
</style>